/* 
 * Memories Version 1.0
 * Developed by Jigar Desai (http://www.jigar.net/) 
 */
using System;

namespace Memories.Entities
{
	/// <summary>
	/// File Object
	/// </summary>
	[Serializable()]
	public class File : IComparable
	{
		string _Name = "";
		string _FullName = "";
        string _RelativePath = "";
		DateTime _CreationTime;
		DateTime _LastAccessTime;
		DateTime _LastWriteTime;
		string _Title = "";
		string _Comment = "";
        Folder _Parent;


		/// <summary>
		/// Name of file.
		/// </summary>
		public string Name { get { return _Name; } set { _Name = value; } }
		
		/// <summary>
		/// Physical Path of File on file system.
		/// </summary>
		public string FullName { get { return _FullName; } set { _FullName = value; } }


        /// <summary>
        /// Friendly path of File.
        /// </summary>
        public string RelativePath { get { return _RelativePath; } set { _RelativePath = value; } }
        
        
        /// <summary>
		/// Time when File was created on file system.
		/// </summary>
		public DateTime CreationTime { get { return _CreationTime; } set { _CreationTime = value; } }
		
		/// <summary>
		/// Time when File was last accessed.
		/// </summary>
		public DateTime LastAccessTime { get { return _LastAccessTime; } set { _LastAccessTime = value; } }
		
		/// <summary>
		/// Time when File was last changed.
		/// </summary>
		public DateTime LastWriteTime { get { return _LastWriteTime; } set { _LastWriteTime = value; } }
		
		/// <summary>
		/// Title of File.
		/// </summary>
		public string Title { get { return _Title; } set { _Title = value; } }
		
		/// <summary>
		/// Comment or Description of file.
		/// </summary>
		public string Comment { get { return _Comment; } set { _Comment = value; } }


        /// <summary>
        /// Reference to parent folder.
        /// </summary>
        public Folder Parent { get { return _Parent; } set { _Parent = value; } }
        
        /// <summary>
        /// Constructor
		/// </summary>
		public File() { }
		
		/// <summary>
        /// Constructor
		/// </summary>
		/// <param name="info">System.IO.FileInfo  info</param>
		public File(System.IO.FileInfo  info)
		{
			_Name = info.Name;
			_FullName = info.FullName;
			_CreationTime = info.CreationTime;
			_LastAccessTime = info.LastAccessTime;
			_LastWriteTime = info.LastWriteTime;
		}

		/// <summary>
		/// Compares using LastWriteTime property.
		/// </summary>
		/// <param name="obj">Object</param>
		/// <returns></returns>
		public int CompareTo(object obj)
		{
			return (int)((this._LastWriteTime.CompareTo(((File)obj).LastWriteTime)) * (-1));
		}

	}

}
